// SEE END OF FILE FOR LICENSE TERMS

#include "../libCAN/libCAN.h"
#include "defines.h"

//	Perform control based on the airframe type.
//	Use the radio to determine the baseline pulse widths if the radio is on.
//	Otherwise, use the trim pulse width measured during power up.
//
//	Mix computed roll and pitch controls into the output channels for the compiled airframe type


const int aileronbgain = (int)(8.0*AILERON_BOOST) ;
const int elevatorbgain = (int)(8.0*ELEVATOR_BOOST) ;
const int rudderbgain = (int)(8.0*RUDDER_BOOST) ;


// Callback when autopilot control otuputs are received
void CAN_received_control_outputs_callback(void)
{
/*	pitch_control 		= CANControlDataBuff[0];
	yaw_control 		= CANControlDataBuff[1];
	roll_control 		= CANControlDataBuff[2];
	altitude_control 	= CANControlDataBuff[3];
	servoMix();
*/
}


void servoMix( void )
{
	CANControlDataBuff[0] = pitch_control;
	CANControlDataBuff[1] = yaw_control;
	CANControlDataBuff[2] = roll_control;
	CANControlDataBuff[3] = altitude_control;
	CANControlDataBuff[4] = waggle;

	CAN_send_control_outputs();
	CAN_send_flags();
}


/****************************************************************************/
// This is part of the servo and radio interface software
//
// ServoInterface source code
//	http://code.google.com/p/rc-servo-interface
//
// Copyright 2010 ServoInterface Team
// See the AUTHORS.TXT file for a list of authors of ServoInterface.
//
// ServoInterface is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ServoInterface is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License 
// along with ServoInterface.  If not, see <http://www.gnu.org/licenses/>.
//
// Many parts of ServoInterface use either modified or unmodified code
// from the MatrixPilot pilot project.
// The project also contains code for modifying MatrixPilot to operate
// with ServoInterface.
// For details, credits and licenses of MatrixPilot see the AUTHORS.TXT file.
// or see this website: http://code.google.com/p/gentlenav
/****************************************************************************/

